package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo5
{
    public static void main(String[] args)
    {
        try(Connection connection = DBUtil.getConnection())
        {
            String sql = "SELECT name ,salary, title, gender from teacher";
            Statement statement = connection.createStatement();
            ResultSet rs = statement.executeQuery(sql);
            while (rs.next())
            {
                String name = rs.getString("name");
                int salary = rs.getInt("salary");
                String title = rs.getString("title");
                String gender = rs.getString("gender");
                System.out.println("name =\t " + name + " salary =\t " + salary + " title =\t " + title  + " gender\t = " + gender);
            }


        }catch (SQLException e)
        {
            e.printStackTrace();
        }
    }
}
